Skip to content

fix: yoga crash with display:none#57197

Closed
5ZYSZ3K wants to merge 1 commit into
react:mainfrom
5ZYSZ3K:fix/yoga-crash-with-display-none
Closed

fix: yoga crash with display:none#57197
5ZYSZ3K wants to merge 1 commit into
react:mainfrom
5ZYSZ3K:fix/yoga-crash-with-display-none

Conversation

@5ZYSZ3K

@5ZYSZ3K 5ZYSZ3K commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary:

It fixes this issue: #52349
Basically, in some rare cases, having an element with display:none style caused the app to crash.

It was caused by a stale hasNewLayout flag on the hidden view
That flag was always set in computeFlexBasisForChildren for elements with display:none style, but could be never consumed/reset, because of a cache hit or something.
Since such elements contribute nothing to the layout sizes, I made the change to actually touch them only during actual layout passes

Changelog:

[GENERAL] [FIXED] - Crash: YogaLayoutableShadowNode.cpp: function layout: assertion failed (YGNodeGetOwner(childYogaNode) == &yogaNode_) #52349

Test Plan:

I created a reproduction repo: https://github.com/5ZYSZ3K/native-tabs-crash-repro, to see the issue
And to see, that my change fixes it, you can switch to patch-yoga branch there, and install it again (don't forget to install pods with RCT_USE_PREBUILT_RNCORE=0 RCT_USE_RN_DEP=0 variables)

@meta-cla

meta-cla Bot commented Jun 13, 2026

Copy link
Copy Markdown

Hi @5ZYSZ3K!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 13, 2026
@meta-cla

meta-cla Bot commented Jun 13, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 13, 2026
@javache

javache commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Was able to repro crash, thanks!

@meta-codesync

meta-codesync Bot commented Jun 16, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D108796888.

@meta-codesync meta-codesync Bot closed this in 6fa3306 Jun 17, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jun 17, 2026
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

@javache merged this pull request in 6fa3306.

meta-codesync Bot pushed a commit to react/yoga that referenced this pull request Jun 17, 2026
Summary:
Pull Request resolved: #1976

It fixes this issue: react/react-native#52349
Basically, in some rare cases, having an element with `display:none` style caused the app to crash.

It was caused by a stale `hasNewLayout` flag on the hidden view
That flag was always set in `computeFlexBasisForChildren` for elements with `display:none` style, but could be never consumed/reset, because of a cache hit or something.
Since such elements contribute nothing to the layout sizes, I made the change to actually touch them only during actual layout passes

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - Crash: YogaLayoutableShadowNode.cpp: function layout: assertion failed (YGNodeGetOwner(childYogaNode) == &yogaNode_) react/react-native#52349

X-link: react/react-native#57197

Test Plan:
I created a reproduction repo: https://github.com/5ZYSZ3K/native-tabs-crash-repro, to see the issue
And to see, that my change fixes it, you can switch to `patch-yoga` branch there, and install it again (don't forget to install pods with `RCT_USE_PREBUILT_RNCORE=0 RCT_USE_RN_DEP=0` variables)

Reviewed By: christophpurrer

Differential Revision: D108796888

Pulled By: javache

fbshipit-source-id: 455e3ddbec760dbee875c02f0ed6266b9a417e9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants